<template>
	<view class="uni-popup-message" style="letter-spacing:4rpx">
		<view>
			<image mode="aspectFit" src="../../static/jinggao.png" style="width: 32rpx;height: 32rpx;"></image>
			<text style="margin-left: 10rpx;">已过期</text>
		</view>
		<view style="display: flex;flex-direction: column;justify-content: center;align-items: flex-start;font-size: 23rpx;">
			<text style=" margin-top: 30rpx;">您好，您的免费次数已用完。</text>
			<view style=" display: flex;">
				<text>您可以:</text>
				<view style="display: flex;flex-direction: column;margin-left: 20rpx;">
					<text>· 1.单次付费</text>
					<text>· 2.开通会员随时算财神</text>
				</view>
			</view>
		</view>
		
		<view style="width: 90%; display: flex;justify-content: space-between; margin-top: 40rpx;">
			<image mode="aspectFit" src="../../static/onepay.png" style="width: 235rpx;height: 70rpx;" @click="onOk"></image>
			<image mode="aspectFit" src="../../static/vippay.png" style="width: 235rpx;height: 70rpx;" @click="close"></image>
		</view>
	</view>
</template>

<script>
	/**
	 * PopUp 弹出层-对话框样式
	 * @description 弹出层-对话框样式
	 * @tutorial https://ext.dcloud.net.cn/plugin?id=329
	 * @property {String} value input 模式下的默认值
	 * @property {String} placeholder input 模式下输入提示
	 * @property {String} type = [success|warning|info|error] 主题样式
	 *  @value success 成功
	 * 	@value warning 提示
	 * 	@value info 消息
	 * 	@value error 错误
	 * @property {String} mode = [base|input] 模式、
	 * 	@value base 基础对话框
	 * 	@value input 可输入对话框
	 * @property {String} content 对话框内容
	 * @property {Boolean} beforeClose 是否拦截取消事件
	 * @event {Function} confirm 点击确认按钮触发
	 * @event {Function} close 点击取消按钮触发
	 */

	export default {
		name: "uniPopupDialog",
		props: {
			value: {
				type: [String, Number],
				default: ''
			},
			placeholder: {
				type: [String, Number],
				default: '请输入内容'
			},
			/**
			 * 对话框主题 success/warning/info/error	  默认 success
			 */
			type: {
				type: String,
				default: 'error'
			},
			/**
			 * 对话框模式 base/input
			 */
			mode: {
				type: String,
				default: 'base'
			},
			/**
			 * 对话框标题
			 */
			title: {
				type: String,
				default: '提示'
			},
			/**
			 * 对话框内容
			 */
			content: {
				type: String,
				default: ''
			},
			/**
			 * 拦截取消事件 ，如果拦截取消事件，必须监听close事件，执行 done()
			 */
			beforeClose: {
				type: Boolean,
				default: false
			}
		},
		data() {
			return {
				dialogType: 'error',
				focus: false,
				val: ""
			}
		},
		inject: ['popup'],
		watch: {
			type(val) {
				this.dialogType = val
			},
			mode(val) {
				if (val === 'input') {
					this.dialogType = 'info'
				}
			},
			value(val) {
				this.val = val
			}
		},
		created() {
			// 对话框遮罩不可点击
			this.popup.mkclick = false
			if (this.mode === 'input') {
				this.dialogType = 'info'
				this.val = this.value
			} else {
				this.dialogType = this.type
			}
		},
		mounted() {
			this.focus = true
		},
		methods: {
			/**
			 * 点击确认按钮
			 */
			onOk() {
				this.$emit('confirm', () => {
					this.popup.close()
					if (this.mode === 'input') this.val = this.value
				}, this.mode === 'input' ? this.val : '')
			},
			/**
			 * 点击取消按钮
			 */
			close() {
				if (this.beforeClose) {
					this.$emit('close', () => {
						this.popup.close()
					})
					return
				}
				this.popup.close()
			}
		}
	}
</script>

<style lang="scss" scoped>
	.uni-popup-message {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		width: 555rpx;
		padding-top: 21rpx;
		padding-bottom: 21rpx;
		background-color: #D45151;
		border-radius: 15rpx;
		box-shadow: 3px 3px 1px #888888;
		font-size: 30rpx;
		color: #FFFFFF;
		
		flex-direction: column;
		justify-content: center;
		align-items: center;
		
	}
	.uni-popup-message-text {
		font-size: 14px;
		padding: 0;
	}
	
	.uni-popup__success {
		background-color: #e1f3d8;
	}
	
	.uni-popup__success-text {
		color: #67C23A;
	}
	
	.uni-popup__warn {
		background-color: #faecd8;
	}
	
	.uni-popup__warn-text {
		color: #E6A23C;
	}
	
	.uni-popup__error {
		background-color: #fde2e2;
	}
	
	.uni-popup__error-text {
		color: #F56C6C;
	}
	
	.uni-popup__info {
		background-color: #F2F6FC;
	}
	
	.uni-popup__info-text {
		color: #909399;
	}
</style>
